// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/bigtable/admin/v2/bigtable_instance_admin.proto

#include "google/cloud/bigtable/admin/bigtable_instance_admin_connection.h"
#include "google/cloud/bigtable/admin/bigtable_instance_admin_options.h"
#include "google/cloud/bigtable/admin/internal/bigtable_instance_admin_option_defaults.h"
#include "google/cloud/bigtable/admin/internal/bigtable_instance_admin_stub_factory.h"
#include "google/cloud/background_threads.h"
#include "google/cloud/common_options.h"
#include "google/cloud/grpc_options.h"
#include "google/cloud/internal/async_long_running_operation.h"
#include "google/cloud/internal/pagination_range.h"
#include "google/cloud/internal/retry_loop.h"
#include <memory>

namespace google {
namespace cloud {
namespace bigtable_admin {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

BigtableInstanceAdminConnection::~BigtableInstanceAdminConnection() = default;

future<StatusOr<google::bigtable::admin::v2::Instance>>
BigtableInstanceAdminConnection::CreateInstance(
    google::bigtable::admin::v2::CreateInstanceRequest const&) {
  return google::cloud::make_ready_future<
      StatusOr<google::bigtable::admin::v2::Instance>>(
      Status(StatusCode::kUnimplemented, "not implemented"));
}

StatusOr<google::bigtable::admin::v2::Instance>
BigtableInstanceAdminConnection::GetInstance(
    google::bigtable::admin::v2::GetInstanceRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::bigtable::admin::v2::ListInstancesResponse>
BigtableInstanceAdminConnection::ListInstances(
    google::bigtable::admin::v2::ListInstancesRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::bigtable::admin::v2::Instance>
BigtableInstanceAdminConnection::UpdateInstance(
    google::bigtable::admin::v2::Instance const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

future<StatusOr<google::bigtable::admin::v2::Instance>>
BigtableInstanceAdminConnection::PartialUpdateInstance(
    google::bigtable::admin::v2::PartialUpdateInstanceRequest const&) {
  return google::cloud::make_ready_future<
      StatusOr<google::bigtable::admin::v2::Instance>>(
      Status(StatusCode::kUnimplemented, "not implemented"));
}

Status BigtableInstanceAdminConnection::DeleteInstance(
    google::bigtable::admin::v2::DeleteInstanceRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

future<StatusOr<google::bigtable::admin::v2::Cluster>>
BigtableInstanceAdminConnection::CreateCluster(
    google::bigtable::admin::v2::CreateClusterRequest const&) {
  return google::cloud::make_ready_future<
      StatusOr<google::bigtable::admin::v2::Cluster>>(
      Status(StatusCode::kUnimplemented, "not implemented"));
}

StatusOr<google::bigtable::admin::v2::Cluster>
BigtableInstanceAdminConnection::GetCluster(
    google::bigtable::admin::v2::GetClusterRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::bigtable::admin::v2::ListClustersResponse>
BigtableInstanceAdminConnection::ListClusters(
    google::bigtable::admin::v2::ListClustersRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

future<StatusOr<google::bigtable::admin::v2::Cluster>>
BigtableInstanceAdminConnection::UpdateCluster(
    google::bigtable::admin::v2::Cluster const&) {
  return google::cloud::make_ready_future<
      StatusOr<google::bigtable::admin::v2::Cluster>>(
      Status(StatusCode::kUnimplemented, "not implemented"));
}

future<StatusOr<google::bigtable::admin::v2::Cluster>>
BigtableInstanceAdminConnection::PartialUpdateCluster(
    google::bigtable::admin::v2::PartialUpdateClusterRequest const&) {
  return google::cloud::make_ready_future<
      StatusOr<google::bigtable::admin::v2::Cluster>>(
      Status(StatusCode::kUnimplemented, "not implemented"));
}

Status BigtableInstanceAdminConnection::DeleteCluster(
    google::bigtable::admin::v2::DeleteClusterRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::bigtable::admin::v2::AppProfile>
BigtableInstanceAdminConnection::CreateAppProfile(
    google::bigtable::admin::v2::CreateAppProfileRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::bigtable::admin::v2::AppProfile>
BigtableInstanceAdminConnection::GetAppProfile(
    google::bigtable::admin::v2::GetAppProfileRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StreamRange<google::bigtable::admin::v2::AppProfile>
BigtableInstanceAdminConnection::ListAppProfiles(
    google::bigtable::admin::v2::ListAppProfilesRequest request) {
  return google::cloud::internal::MakePaginationRange<
      StreamRange<google::bigtable::admin::v2::AppProfile>>(
      std::move(request),
      [](google::bigtable::admin::v2::ListAppProfilesRequest const&) {
        return StatusOr<google::bigtable::admin::v2::ListAppProfilesResponse>{};
      },
      [](google::bigtable::admin::v2::ListAppProfilesResponse const&) {
        return std::vector<google::bigtable::admin::v2::AppProfile>();
      });
}

future<StatusOr<google::bigtable::admin::v2::AppProfile>>
BigtableInstanceAdminConnection::UpdateAppProfile(
    google::bigtable::admin::v2::UpdateAppProfileRequest const&) {
  return google::cloud::make_ready_future<
      StatusOr<google::bigtable::admin::v2::AppProfile>>(
      Status(StatusCode::kUnimplemented, "not implemented"));
}

Status BigtableInstanceAdminConnection::DeleteAppProfile(
    google::bigtable::admin::v2::DeleteAppProfileRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::iam::v1::Policy> BigtableInstanceAdminConnection::GetIamPolicy(
    google::iam::v1::GetIamPolicyRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::iam::v1::Policy> BigtableInstanceAdminConnection::SetIamPolicy(
    google::iam::v1::SetIamPolicyRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::iam::v1::TestIamPermissionsResponse>
BigtableInstanceAdminConnection::TestIamPermissions(
    google::iam::v1::TestIamPermissionsRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

namespace {
class BigtableInstanceAdminConnectionImpl
    : public BigtableInstanceAdminConnection {
 public:
  BigtableInstanceAdminConnectionImpl(
      std::unique_ptr<google::cloud::BackgroundThreads> background,
      std::shared_ptr<bigtable_admin_internal::BigtableInstanceAdminStub> stub,
      Options const& options)
      : background_(std::move(background)),
        stub_(std::move(stub)),
        retry_policy_prototype_(
            options.get<BigtableInstanceAdminRetryPolicyOption>()->clone()),
        backoff_policy_prototype_(
            options.get<BigtableInstanceAdminBackoffPolicyOption>()->clone()),
        polling_policy_prototype_(
            options.get<BigtableInstanceAdminPollingPolicyOption>()->clone()),
        idempotency_policy_(
            options
                .get<BigtableInstanceAdminConnectionIdempotencyPolicyOption>()
                ->clone()) {}

  ~BigtableInstanceAdminConnectionImpl() override = default;

  future<StatusOr<google::bigtable::admin::v2::Instance>> CreateInstance(
      google::bigtable::admin::v2::CreateInstanceRequest const& request)
      override {
    auto stub = stub_;
    return google::cloud::internal::AsyncLongRunningOperation<
        google::bigtable::admin::v2::Instance>(
        background_->cq(), request,
        [stub](
            google::cloud::CompletionQueue& cq,
            std::unique_ptr<grpc::ClientContext> context,
            google::bigtable::admin::v2::CreateInstanceRequest const& request) {
          return stub->AsyncCreateInstance(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::GetOperationRequest const& request) {
          return stub->AsyncGetOperation(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::CancelOperationRequest const& request) {
          return stub->AsyncCancelOperation(cq, std::move(context), request);
        },
        &google::cloud::internal::ExtractLongRunningResultResponse<
            google::bigtable::admin::v2::Instance>,
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->CreateInstance(request),
        polling_policy_prototype_->clone(), __func__);
  }

  StatusOr<google::bigtable::admin::v2::Instance> GetInstance(
      google::bigtable::admin::v2::GetInstanceRequest const& request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->GetInstance(request),
        [this](grpc::ClientContext& context,
               google::bigtable::admin::v2::GetInstanceRequest const& request) {
          return stub_->GetInstance(context, request);
        },
        request, __func__);
  }

  StatusOr<google::bigtable::admin::v2::ListInstancesResponse> ListInstances(
      google::bigtable::admin::v2::ListInstancesRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->ListInstances(request),
        [this](
            grpc::ClientContext& context,
            google::bigtable::admin::v2::ListInstancesRequest const& request) {
          return stub_->ListInstances(context, request);
        },
        request, __func__);
  }

  StatusOr<google::bigtable::admin::v2::Instance> UpdateInstance(
      google::bigtable::admin::v2::Instance const& request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->UpdateInstance(request),
        [this](grpc::ClientContext& context,
               google::bigtable::admin::v2::Instance const& request) {
          return stub_->UpdateInstance(context, request);
        },
        request, __func__);
  }

  future<StatusOr<google::bigtable::admin::v2::Instance>> PartialUpdateInstance(
      google::bigtable::admin::v2::PartialUpdateInstanceRequest const& request)
      override {
    auto stub = stub_;
    return google::cloud::internal::AsyncLongRunningOperation<
        google::bigtable::admin::v2::Instance>(
        background_->cq(), request,
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::bigtable::admin::v2::PartialUpdateInstanceRequest const&
                   request) {
          return stub->AsyncPartialUpdateInstance(cq, std::move(context),
                                                  request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::GetOperationRequest const& request) {
          return stub->AsyncGetOperation(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::CancelOperationRequest const& request) {
          return stub->AsyncCancelOperation(cq, std::move(context), request);
        },
        &google::cloud::internal::ExtractLongRunningResultResponse<
            google::bigtable::admin::v2::Instance>,
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->PartialUpdateInstance(request),
        polling_policy_prototype_->clone(), __func__);
  }

  Status DeleteInstance(
      google::bigtable::admin::v2::DeleteInstanceRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->DeleteInstance(request),
        [this](
            grpc::ClientContext& context,
            google::bigtable::admin::v2::DeleteInstanceRequest const& request) {
          return stub_->DeleteInstance(context, request);
        },
        request, __func__);
  }

  future<StatusOr<google::bigtable::admin::v2::Cluster>> CreateCluster(
      google::bigtable::admin::v2::CreateClusterRequest const& request)
      override {
    auto stub = stub_;
    return google::cloud::internal::AsyncLongRunningOperation<
        google::bigtable::admin::v2::Cluster>(
        background_->cq(), request,
        [stub](
            google::cloud::CompletionQueue& cq,
            std::unique_ptr<grpc::ClientContext> context,
            google::bigtable::admin::v2::CreateClusterRequest const& request) {
          return stub->AsyncCreateCluster(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::GetOperationRequest const& request) {
          return stub->AsyncGetOperation(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::CancelOperationRequest const& request) {
          return stub->AsyncCancelOperation(cq, std::move(context), request);
        },
        &google::cloud::internal::ExtractLongRunningResultResponse<
            google::bigtable::admin::v2::Cluster>,
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->CreateCluster(request),
        polling_policy_prototype_->clone(), __func__);
  }

  StatusOr<google::bigtable::admin::v2::Cluster> GetCluster(
      google::bigtable::admin::v2::GetClusterRequest const& request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->GetCluster(request),
        [this](grpc::ClientContext& context,
               google::bigtable::admin::v2::GetClusterRequest const& request) {
          return stub_->GetCluster(context, request);
        },
        request, __func__);
  }

  StatusOr<google::bigtable::admin::v2::ListClustersResponse> ListClusters(
      google::bigtable::admin::v2::ListClustersRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->ListClusters(request),
        [this](
            grpc::ClientContext& context,
            google::bigtable::admin::v2::ListClustersRequest const& request) {
          return stub_->ListClusters(context, request);
        },
        request, __func__);
  }

  future<StatusOr<google::bigtable::admin::v2::Cluster>> UpdateCluster(
      google::bigtable::admin::v2::Cluster const& request) override {
    auto stub = stub_;
    return google::cloud::internal::AsyncLongRunningOperation<
        google::bigtable::admin::v2::Cluster>(
        background_->cq(), request,
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::bigtable::admin::v2::Cluster const& request) {
          return stub->AsyncUpdateCluster(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::GetOperationRequest const& request) {
          return stub->AsyncGetOperation(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::CancelOperationRequest const& request) {
          return stub->AsyncCancelOperation(cq, std::move(context), request);
        },
        &google::cloud::internal::ExtractLongRunningResultResponse<
            google::bigtable::admin::v2::Cluster>,
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->UpdateCluster(request),
        polling_policy_prototype_->clone(), __func__);
  }

  future<StatusOr<google::bigtable::admin::v2::Cluster>> PartialUpdateCluster(
      google::bigtable::admin::v2::PartialUpdateClusterRequest const& request)
      override {
    auto stub = stub_;
    return google::cloud::internal::AsyncLongRunningOperation<
        google::bigtable::admin::v2::Cluster>(
        background_->cq(), request,
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::bigtable::admin::v2::PartialUpdateClusterRequest const&
                   request) {
          return stub->AsyncPartialUpdateCluster(cq, std::move(context),
                                                 request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::GetOperationRequest const& request) {
          return stub->AsyncGetOperation(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::CancelOperationRequest const& request) {
          return stub->AsyncCancelOperation(cq, std::move(context), request);
        },
        &google::cloud::internal::ExtractLongRunningResultResponse<
            google::bigtable::admin::v2::Cluster>,
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->PartialUpdateCluster(request),
        polling_policy_prototype_->clone(), __func__);
  }

  Status DeleteCluster(google::bigtable::admin::v2::DeleteClusterRequest const&
                           request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->DeleteCluster(request),
        [this](
            grpc::ClientContext& context,
            google::bigtable::admin::v2::DeleteClusterRequest const& request) {
          return stub_->DeleteCluster(context, request);
        },
        request, __func__);
  }

  StatusOr<google::bigtable::admin::v2::AppProfile> CreateAppProfile(
      google::bigtable::admin::v2::CreateAppProfileRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->CreateAppProfile(request),
        [this](grpc::ClientContext& context,
               google::bigtable::admin::v2::CreateAppProfileRequest const&
                   request) {
          return stub_->CreateAppProfile(context, request);
        },
        request, __func__);
  }

  StatusOr<google::bigtable::admin::v2::AppProfile> GetAppProfile(
      google::bigtable::admin::v2::GetAppProfileRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->GetAppProfile(request),
        [this](
            grpc::ClientContext& context,
            google::bigtable::admin::v2::GetAppProfileRequest const& request) {
          return stub_->GetAppProfile(context, request);
        },
        request, __func__);
  }

  StreamRange<google::bigtable::admin::v2::AppProfile> ListAppProfiles(
      google::bigtable::admin::v2::ListAppProfilesRequest request) override {
    request.clear_page_token();
    auto stub = stub_;
    auto retry = std::shared_ptr<BigtableInstanceAdminRetryPolicy const>(
        retry_policy_prototype_->clone());
    auto backoff = std::shared_ptr<BackoffPolicy const>(
        backoff_policy_prototype_->clone());
    auto idempotency = idempotency_policy_->ListAppProfiles(request);
    char const* function_name = __func__;
    return google::cloud::internal::MakePaginationRange<
        StreamRange<google::bigtable::admin::v2::AppProfile>>(
        std::move(request),
        [stub, retry, backoff, idempotency, function_name](
            google::bigtable::admin::v2::ListAppProfilesRequest const& r) {
          return google::cloud::internal::RetryLoop(
              retry->clone(), backoff->clone(), idempotency,
              [stub](grpc::ClientContext& context,
                     google::bigtable::admin::v2::ListAppProfilesRequest const&
                         request) {
                return stub->ListAppProfiles(context, request);
              },
              r, function_name);
        },
        [](google::bigtable::admin::v2::ListAppProfilesResponse r) {
          std::vector<google::bigtable::admin::v2::AppProfile> result(
              r.app_profiles().size());
          auto& messages = *r.mutable_app_profiles();
          std::move(messages.begin(), messages.end(), result.begin());
          return result;
        });
  }

  future<StatusOr<google::bigtable::admin::v2::AppProfile>> UpdateAppProfile(
      google::bigtable::admin::v2::UpdateAppProfileRequest const& request)
      override {
    auto stub = stub_;
    return google::cloud::internal::AsyncLongRunningOperation<
        google::bigtable::admin::v2::AppProfile>(
        background_->cq(), request,
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::bigtable::admin::v2::UpdateAppProfileRequest const&
                   request) {
          return stub->AsyncUpdateAppProfile(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::GetOperationRequest const& request) {
          return stub->AsyncGetOperation(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::CancelOperationRequest const& request) {
          return stub->AsyncCancelOperation(cq, std::move(context), request);
        },
        &google::cloud::internal::ExtractLongRunningResultResponse<
            google::bigtable::admin::v2::AppProfile>,
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->UpdateAppProfile(request),
        polling_policy_prototype_->clone(), __func__);
  }

  Status DeleteAppProfile(
      google::bigtable::admin::v2::DeleteAppProfileRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->DeleteAppProfile(request),
        [this](grpc::ClientContext& context,
               google::bigtable::admin::v2::DeleteAppProfileRequest const&
                   request) {
          return stub_->DeleteAppProfile(context, request);
        },
        request, __func__);
  }

  StatusOr<google::iam::v1::Policy> GetIamPolicy(
      google::iam::v1::GetIamPolicyRequest const& request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->GetIamPolicy(request),
        [this](grpc::ClientContext& context,
               google::iam::v1::GetIamPolicyRequest const& request) {
          return stub_->GetIamPolicy(context, request);
        },
        request, __func__);
  }

  StatusOr<google::iam::v1::Policy> SetIamPolicy(
      google::iam::v1::SetIamPolicyRequest const& request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->SetIamPolicy(request),
        [this](grpc::ClientContext& context,
               google::iam::v1::SetIamPolicyRequest const& request) {
          return stub_->SetIamPolicy(context, request);
        },
        request, __func__);
  }

  StatusOr<google::iam::v1::TestIamPermissionsResponse> TestIamPermissions(
      google::iam::v1::TestIamPermissionsRequest const& request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->TestIamPermissions(request),
        [this](grpc::ClientContext& context,
               google::iam::v1::TestIamPermissionsRequest const& request) {
          return stub_->TestIamPermissions(context, request);
        },
        request, __func__);
  }

 private:
  std::unique_ptr<google::cloud::BackgroundThreads> background_;
  std::shared_ptr<bigtable_admin_internal::BigtableInstanceAdminStub> stub_;
  std::unique_ptr<BigtableInstanceAdminRetryPolicy const>
      retry_policy_prototype_;
  std::unique_ptr<BackoffPolicy const> backoff_policy_prototype_;
  std::unique_ptr<PollingPolicy const> polling_policy_prototype_;
  std::unique_ptr<BigtableInstanceAdminConnectionIdempotencyPolicy>
      idempotency_policy_;
};
}  // namespace

std::shared_ptr<BigtableInstanceAdminConnection>
MakeBigtableInstanceAdminConnection(Options options) {
  internal::CheckExpectedOptions<CommonOptionList, GrpcOptionList,
                                 BigtableInstanceAdminPolicyOptionList>(
      options, __func__);
  options = bigtable_admin_internal::BigtableInstanceAdminDefaultOptions(
      std::move(options));
  auto background = internal::MakeBackgroundThreadsFactory(options)();
  auto stub = bigtable_admin_internal::CreateDefaultBigtableInstanceAdminStub(
      background->cq(), options);
  return std::make_shared<BigtableInstanceAdminConnectionImpl>(
      std::move(background), std::move(stub), options);
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
}  // namespace bigtable_admin
}  // namespace cloud
}  // namespace google

namespace google {
namespace cloud {
namespace bigtable_admin_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

std::shared_ptr<bigtable_admin::BigtableInstanceAdminConnection>
MakeBigtableInstanceAdminConnection(
    std::shared_ptr<BigtableInstanceAdminStub> stub, Options options) {
  options = BigtableInstanceAdminDefaultOptions(std::move(options));
  return std::make_shared<bigtable_admin::BigtableInstanceAdminConnectionImpl>(
      internal::MakeBackgroundThreadsFactory(options)(), std::move(stub),
      std::move(options));
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
}  // namespace bigtable_admin_internal
}  // namespace cloud
}  // namespace google
